home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news3.noc.netcom.net!zdc!zippo!usenet
- From: Jim McFarland <jgm6@orkand.em.cdc.gov>
- Subject: Re: void pointers
- Content-Type: text/plain; charset=us-ascii
- Sender: usenet@news.zippo.com
- Content-Transfer-Encoding: 7bit
- Nntp-Posting-Host: 158.111.166.77
- Organization: The Orkand Corporation
- Message-ID: <DKx5H9.1rF@news.zippo.com>
- References: <Pine.SUN.3.91.960105113409.18158A-100000@phoenix.acms.arizona.edu>
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
- Mime-Version: 1.0
- Date: Tue, 9 Jan 1996 14:55:57 GMT
-
- Kenton White <jwhite@phoenix.acms.arizona.edu> wrote:
- >
- >
- >I am trying to create a class that stores pointers to other classes in an
- >array of void pointers. Since void pointers cannot be dereferenced, is
- >there any way to cast the void pointer to a non-void pointer and then
- >dereference?
- >
- You are trying to use a very C-oriented solution, instead of taking
- advantage of the power of object-oriented programming offered by C++.
- What you are trying to create is a container class. Your compiler may
- already provide a class that will do this. If not, you should use
- polymorphism to create a container that can contain pointers to various
- classes, without needing to use void pointers. To do this, your classes
- will need to have a common base class.
-
-